import { defineStore } from 'pinia'
import { req_category_2_list_list, req_CourseList } from '../api/req_fun'

export default defineStore('Course', {
    state: () => ({
        Cate_1_list: [],
        AllCata_2_list: [],
        CouserList: [],
        CouserListTotal: 0
    }),
    actions: {
        async GetAllCate_2_list() {
            // 获取全部二级分类列表
            try {
                const { data } = await req_category_2_list_list(-1)
                this.$patch((state) => {
                    state.AllCata_2_list = data.data.list
                })
            } catch (err) {
                console.log(err);
            }
        },
        // 获取Course列表
        async GetCouser(ReqData) {
            try {
                const { data } = await req_CourseList(ReqData)
                this.CouserList = data.data.pageInfo.list
                this.CouserListTotal = data.data.pageInfo.total
            } catch (err) {
                console.log(err);
            }

        }
    },
    getters: {

    }
})